<?php

namespace app\admin\model\fas;

use think\Model;


class Zcorder extends Model
{

    

    

    // 表名
    protected $table = 'fas_zcorder';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'cgstate_text',
        'dbstate_text',
        'ysstate_text',
        'state_text'
    ];
    

    
    public function getCgstateList()
    {
        return ['0' => __('Cgstate 0'), '1' => __('Cgstate 1'), '2' => __('Cgstate 2')];
    }

    public function getDbstateList()
    {
        return ['0' => __('Dbstate 0'), '1' => __('Dbstate 1'), '2' => __('Dbstate 2'), '3' => __('Dbstate 3')];
    }

    public function getYsstateList()
    {
        return ['0' => __('Ysstate 0'), '1' => __('Ysstate 1')];
    }

    public function getStateList()
    {
        return ['0' => __('State 0'), '1' => __('State 1'), '2' => __('State 2')];
    }


    public function getCgstateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cgstate']) ? $data['cgstate'] : '');
        $list = $this->getCgstateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDbstateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['dbstate']) ? $data['dbstate'] : '');
        $list = $this->getDbstateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getYsstateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['ysstate']) ? $data['ysstate'] : '');
        $list = $this->getYsstateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function zctype()
    {
        return $this->belongsTo('Zctype', 'zctype_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
